<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package cs5620.object;
import javax.vecmath.*;

import cs5620.material.CookTorrance;
import cs5620.material.Lambertian;


public class Robot implements ParameterizedObjectMaker {
	
	public Robot(){
		
	}
	
	public HierarchicalObject make(Object... inputs){
		Scene newScene = new Scene();
		
		MeshObject plane = PrimitiveFactory.makePlane("Plane");
		plane.setTranslate(0, -1.0f, 0);
		plane.setMaterial(new Lambertian(new Color3f(0.2f, 0.2f, 0.5f)));
			
		
		//Head and Neck
		
		Group neck = new Group("Neck");
		
		float neckLengthScale = 1f;
		if(inputs.length == 1)
			neckLengthScale = (Float)inputs[0];
		

		float neckPosY = 0.50f + ((neckLengthScale-1) * 0.07f);
		float headPosY = neckPosY + 0.20f + (neckLengthScale * 0.07f);
		
		MeshObject onlyNeck = PrimitiveFactory.makeCylinder(10,30, "Neck");
		onlyNeck.setTranslate(0.0f, neckPosY, 0.0f);
		onlyNeck.setScale(0.1f, neckLengthScale* 0.07f, 0.1f);
		onlyNeck.setMaterial(new Lambertian(new Color3f(0.05f, 0.50f, 0.5f)));
		
		Group mainHead = new Group("MainHead");
		//make eyes,nose etc
		
		
		MeshObject head = PrimitiveFactory.makeSphere(10,30, "Head");
		head.setTranslate(0.0f,  headPosY, 0.0f);
		head.setScale(0.20f, 0.20f, 0.20f);
		head.setMaterial(new Lambertian(new Color3f(0.05f, 0.25f, 0.5f)));
		
		mainHead.addObject(head);
		neck.addObject(onlyNeck);
		neck.addObject(mainHead);
		
		//arms and hands
		Group arms = new Group("Arms");
		
		float armRotScale = 9f, temp = 9f;
		if(inputs.length == 2)
			temp = (Float)inputs[1];
		if(temp == 0)
			armRotScale = 9f;
		else
			armRotScale = temp;
		
		MeshObject armOne = PrimitiveFactory.makeCylinder(10,30, "ArmOne");
		armOne.setTranslate(0.0f, 0.1f, 0.5f);
		armOne.setScale(0.1f, 0.25f, 0.1f);
		armOne.setRotationAxisAngle(armRotScale * 10.0f, 0.0f, 0.0f, 1.0f);
		armOne.mulRotation(armRotScale * 10.0f, 0.0f, 0.0f ,1.0f);
		if(armRotScale != 9)
			armOne.setTranslate((armRotScale/9) * 1.0f, 0.1f, 0.5f);
		armOne.setMaterial(new Lambertian(new Color3f(0.05f, 0.50f, 0.5f)));
		
		MeshObject armTwo = PrimitiveFactory.makeCylinder(10,30, "ArmTwo");
		armTwo.setTranslate(0.0f, 0.1f, -0.5f);
		armTwo.setScale(0.1f, 0.25f, 0.1f);
		armTwo.setRotationAxisAngle(armRotScale * 10.0f, 0.0f, 0.0f, 1.0f);
		armTwo.mulRotation(armRotScale * 10.0f, 0.0f, 0.0f ,1.0f);
		if(armRotScale != 9)
			armTwo.setTranslate((armRotScale/9) * 1.0f, 0.1f, -0.5f);
		armTwo.setMaterial(new Lambertian(new Color3f(0.05f, 0.50f, 0.5f)));
		
		MeshObject handOne = PrimitiveFactory.makeCone(10, 30, "HandOne");
		handOne.setTranslate(0.0f, -0.15f, 0.5f);
		handOne.setScale(0.1f, 0.1f, 0.1f);
		if(armRotScale != 9)
		{
			handOne.setRotationAxisAngle(armRotScale * 10.0f, 0.0f, 0.0f, 1.0f);
			handOne.mulRotation(armRotScale * 10.0f, 0.0f, 0.0f ,1.0f);
			handOne.setTranslate((armRotScale/4.65f) * 1.0f, (armRotScale/45f) * 0.8f, 0.5f);
		}
		handOne.setMaterial(new Lambertian(new Color3f(0.05f, 0.05f, 0.5f)));
		
		MeshObject handTwo = PrimitiveFactory.makeCone(10,30,"HandTwo");
		handTwo.setTranslate(0.0f, -0.15f, -0.5f);
		handTwo.setScale(0.1f, 0.1f, 0.1f);
		if(armRotScale != 9)
		{
			handTwo.setRotationAxisAngle(armRotScale * 10.0f, 0.0f, 0.0f, 1.0f);
			handTwo.mulRotation(armRotScale * 10.0f, 0.0f, 0.0f ,1.0f);
			handTwo.setTranslate((armRotScale/4.65f) * 1.0f, (armRotScale/45f) * 0.8f, -0.5f);
		}
		handTwo.setMaterial(new Lambertian(new Color3f(0.05f, 0.05f, 0.5f)));
		
		arms.addObject(handOne);
		arms.addObject(handTwo);
		arms.addObject(armOne);
		arms.addObject(armTwo);
		
		//Main Body
		MeshObject body = PrimitiveFactory.makeBox("Body");
		body.setTranslate(0.0f, 0.08f, 0.0f);
		body.setScale(0.17f, 0.35f, 0.40f);
		body.setMaterial(new CookTorrance(new Color3f(0.8f, 0.55f, 0.3f),
				new Color3f(0.8f, 0.55f, 0.3f), 0.6f, 1.7f));
		
		
		//Legs and Feet

		Group legs = new Group("Legs");
		
		MeshObject footOne = PrimitiveFactory.makeBox("FootOne");
		footOne.setTranslate(0.15f, -0.90f, 0.25f);
		footOne.setScale(0.25f, 0.1f, 0.10f);
		footOne.setMaterial(new Lambertian(new Color3f(0.05f, 0.05f, 0.5f)));
		
		MeshObject footTwo = PrimitiveFactory.makeBox("FootTwo");
		footTwo.setTranslate(0.15f, -0.90f, -0.25f);
		footTwo.setScale(0.25f, 0.1f, 0.10f);
		footTwo.setMaterial(new Lambertian(new Color3f(0.05f, 0.05f, 0.5f)));
		
		float legsLengthScale = 1f;
		if(inputs.length == 3)
			legsLengthScale = (Float)inputs[2];
		
		MeshObject legOne = PrimitiveFactory.makeCylinder(10, 30, "LegOne");
		legOne.setTranslate(0.0f, -0.5f, -0.25f);
		legOne.setScale(0.1f, legsLengthScale * 0.3f, 0.1f);
		legOne.setMaterial(new Lambertian(new Color3f(0.5f, 0.05f, 0.05f)));
		//legOne.addObject(footOne);
		
		MeshObject legTwo = PrimitiveFactory.makeCylinder(10, 30, "LegTwo");
		legTwo.setTranslate(0.0f, -0.5f, 0.25f);
		legTwo.setScale(0.1f, legsLengthScale * 0.3f, 0.1f);
		legTwo.setMaterial(new Lambertian(new Color3f(0.5f, 0.05f, 0.05f)));
		//legTwo.addObject(footTwo);
		
		legs.addObject(legOne);
		legs.addObject(legTwo);
		legs.addObject(footOne);
		legs.addObject(footTwo);
		
		
		Group torso = new Group("Torso");
		torso.addObject(body);
		torso.addObject(legs);
		torso.addObject(arms);
		torso.addObject(neck);
		
		Group robot = new Group("Robot");
		robot.addObject(torso);
		
		newScene.addObject(plane);
		
		newScene.addObject(robot);
		return newScene;
		
	}
	
	
}
</pre></body></html>